package com.feisuanyz.lyweb01.controller;

import com.feisuanyz.lyweb01.constant.ResultCodeConstant;
import com.feisuanyz.lyweb01.pojo.domain.AboutUsDO;
import com.feisuanyz.lyweb01.pojo.dto.AboutUsUpdateDTO;
import com.feisuanyz.lyweb01.pojo.dto.RestResult;
import com.feisuanyz.lyweb01.pojo.dto.UpdateGroup;
import com.feisuanyz.lyweb01.service.AboutUsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.lang.Boolean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * AboutUsController
 *
 * @author deng
 * @date 2025-02-26 11:57:37
 */
@Tag(name = "AboutUsController")
@RequestMapping("about-us")
@RestController
public class AboutUsController {

    @Autowired
    private AboutUsService aboutUsService;

    /**
     * info
     *
     * @return
     */
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @Operation(summary = "info")
    public RestResult<AboutUsDO> getAboutUsInfo() {
        AboutUsDO result = aboutUsService.getAboutUsInfo();
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * update
     *
     * @param aboutUsUpdateDTO 关于我们更新DTO
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @Operation(summary = "update")
    public RestResult<Boolean> updateAboutUsInfo(@Validated(UpdateGroup.class) AboutUsUpdateDTO aboutUsUpdateDTO) {
        Boolean result = aboutUsService.updateAboutUsInfo(aboutUsUpdateDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }
}
